package it.unicam.fishpass.prism;

import java.util.ArrayList;
import java.util.Arrays;

public class Qvi {

	private String location;
	private int[] clocks;
	// boolean variables are considered like this: 0 (false) and 1 (true)
	private float[] variables;

	Qvi(String location, int L1, ArrayList<Declaration> listOfVariables) {
		  this.location = location;
		  clocks = new int[L1];
		  for(int i = 0; i < clocks.length; i++)
		   clocks[i] = 0;
		  variables = new float[listOfVariables.size()];
		  for(int i = 0; i < variables.length; i++)
		   variables[i] = listOfVariables.get(i).getValue();
		 }

	Qvi(String location, int[] L1, float[] L2) {
		this.location = location;
		clocks = Arrays.copyOf(L1, L1.length);
		variables = Arrays.copyOf(L2, L2.length);
	}

	String getLocation() {
		return location;
	}
	
	int[] getClocks() {
		return clocks;
	}
	void makeTimePass()
	{
		for (int i = 0; i < clocks.length; i++)
			clocks[i]++;
	}
	
	int getTime() {
		return clocks[clocks.length - 1];
	}

	float[] getVariables() {
		return variables;
	}
	
	@Override
	public String toString() {
		StringBuilder sb = new StringBuilder();
		for (int clock : clocks)
			sb.append(clock + "_");
		sb.replace(sb.length() - 1, sb.length(), "").append("__");
		for (float variable : variables)
			sb.append((variable + "").replace(".0", "") + "_");
		return location + "__" + sb.toString().substring(0, sb.length() - 1); // location_clocks_variables
	}
	}